package dd.lo.chapter7;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Scalar;

/**
 * 对应Chapter7的Exercise
 * 由于JAVA版接口没有RNG，故只好用randu接口生成随机数
 */
public class Example1 {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        //Exercise 1
        Core.setRNGSeed((int) System.currentTimeMillis());
        Mat mat1 = new Mat(1, 3, CvType.CV_32F);
        Core.randu(mat1, 0, 1.0);
        System.out.println("Random by randu(): ");
        System.out.println(mat1.dump());
        Mat mat2 = new Mat(1, 10, CvType.CV_8UC1);
        Core.randu(mat2, 0, 256.0);
        System.out.println("Random by randu() 0~255: ");
        System.out.println(mat2.dump());
    }
}
